package demo;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-15
 * Time: 12:14
 */
public class Test {


    public static void main(String[] args) {
        String str = "hello world";
        System.out.println(str.substring(1));
        System.out.println(str.substring(0, 5));
    }

    public static void main11(String[] args) {
        String str = "192,168,111";
        String[] ret = str.split(",");
        for (String s : ret) {
            System.out.print(s + " ");
        }
    }

    public static void main10(String[] args) {
        String str = "aaaaabbbbbbb";
        System.out.println(str.replace("a", "1"));
        System.out.println(str.replaceAll("b", "1"));
        System.out.println(str.replaceFirst("b", "1"));
    }

    public static void main9(String[] args) {
        String str = "abcd";
        char[] ch = str.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            System.out.print(ch[i] + " ");
        }
    }

    public static void main8(String[] args) {
        //数字转字符串
        String str1 = String.valueOf(123);
        String str2 = String.valueOf(1.2);
        String str3 = String.valueOf(false);
        int a = Integer.parseInt("111");
        double d = Double.parseDouble("11.1");
        Boolean b = Boolean.parseBoolean("true");
        System.out.println(a);
        System.out.println(d);
        System.out.println(b);
    }

    public static void main7(String[] args) {
        String str = "abcdabe";
        System.out.println(str.lastIndexOf('b'));
        System.out.println(str.lastIndexOf('b', 2));
        System.out.println(str.lastIndexOf("bcd"));
        System.out.println(str.lastIndexOf("bcd", 3));
    }

    public static void main6(String[] args) {
        String str = "abcdabe";
        System.out.println(str.indexOf('b'));
        System.out.println(str.indexOf('b', 2));
        System.out.println(str.indexOf("bcd"));
        System.out.println(str.indexOf("bcd", 3));

/*        String str = "abcd";
        System.out.println(str.charAt(1));*/
    }

    public static void main5(String[] args) {
        String str1 = "abcd";
        String str2 = "bcde";
        String str3 = "bcde";
        String str4 = "ffff";
        System.out.println(str1.compareTo(str2));
        System.out.println(str2.compareTo(str3));
        System.out.println(str4.compareTo(str1));
        System.out.println(str4.compareToIgnoreCase(str1));
    }

    public static void main4(String[] args) {
        String str1 = "abcd";
        String str2 = "bcde";
        String str3 = "bcde";
        System.out.println(str1.equals(str2));
        System.out.println(str2.equals(str3));
    }

    public static void main3(String[] args) {
        StringBuffer str = new StringBuffer("abcdefghijklmn");
/*        str.setLength(10);
        System.out.println(str);*/
        str.append("  ", 1, 1);
        System.out.println(str);
    }

    public static void main2(String[] args) {
        int[] arr = new int[10];
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void main1(String[] args) {
        int[] arr = new int[10];
//        Arrays.fill(arr, 1);
        Arrays.fill(arr, 1, 9, 999);
        for (int x : arr) {
            System.out.print(x + " ");
        }
    }
}
